<?php use model\userModel;
    use Controller\Controller;

    class userController extends Controller {
        private $USER;

        function __construct() {
            $this->USER = new userModel();
        }

        public function indexAction() {
            print_r(__DIR__);
        }

        public function getAction($params = false) {
            $response = [];
            if ($this->request()["method"] !== "GET") {
                $this->errorJsonDie(400);
            }
            if (!$params) {
                $response = $this->USER->getAllUsers();
            } else {
                $response = $this->USER->getUserBy($params);
            }
            $this->successJson($response);
        }

        public function registrationAction() {
            $request = $this->request();

            if ($request["method"] !== "POST") {
                $this->errorJsonDie(404);
            }

            $phone = $request["json"]["phone"];

            $response = $this->USER->addUser($phone);

            $this->successJson($response);
        }

    }